I = imread('fig6.tif');
J = imnoise(I,'gaussian',0,0.01);
h = ones(5,5) / 25;
K = filter2(h,J);
subplot(1,3,1),imshow(I),title('原图');
subplot(1,3,2),imshow(J),title('添加噪声');
subplot(1,3,3),imshow(K/255),title('自定义平均滤波器处理');